package com.company.project.service.impl;

import com.company.project.dao.PeriodicalsDbRMapper;
import com.company.project.model.PeriodicalsDbR;
import com.company.project.service.PeriodicalsDbRService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by CodeGenerator on 2018/10/08.
 */
@Service
@Transactional
public class PeriodicalsDbRServiceImpl extends AbstractService<PeriodicalsDbR> implements PeriodicalsDbRService {
    @Resource
    private PeriodicalsDbRMapper periodicalsDbRMapper;

    //后台添加设置收录数据库
    @Override
    public Integer adminAddPeriodicalsDbR(List<PeriodicalsDbR> periodicalsDbR) {
        return periodicalsDbRMapper.insertList(periodicalsDbR);
    }

    //后台修改设置收录数据库
    @Override
    public Integer adminUpdatePeriodicalsDbR(PeriodicalsDbR periodicalsDbR) {
        Example example = new Example(PeriodicalsDbR.class);
        Example.Criteria criteria= example.createCriteria();
        criteria.andEqualTo("dbid",periodicalsDbR.getOldDbid());
        criteria.andEqualTo("pid",periodicalsDbR.getPid());
        return periodicalsDbRMapper.updateByConditionSelective(periodicalsDbR,example);
    }

    //后台根据pid删除
    @Override
    public Integer adminDelectByPid(Integer pid) {
        return periodicalsDbRMapper.adminDelectByPid(pid);
    }
}
